<div class="giveHeight"> 
    <table id="list_devis" class="responsive dynamicTable display table table-bordered dataTable">
        <thead>        
            <tr>
{# sorting of properties based on query components #}
                    {{ knp_pagination_sortable(pagination, 'N° Devis', 'd.reference') }}
                                {{ knp_pagination_sortable(pagination, 'Raison Social', 'd.client') }}
                    <th>Date</th>
                    <th>Heure</th>
                    <th>Montant TTc</th>

                </tr>
            </thead>
            <tbody>

{# table body #}
{% for devis in pagination %}
                <tr {% if loop.index is odd %}class="color"{% endif %} style="cursor: pointer" onclick="selectDevis(this, '{{devis.id}}')">
                    <td style="width:10%;text-align: center">{{ devis.reference }}</td>
                    <td style="width:15%">{{ devis.client }}</td>
                    <td style="width:15%">{{ devis.date|date('d/m/Y') }} </td>
                    <td style="width:15%"> {{ devis.getTime }}</td>
                    <td style="width:15%">{{ devis.montantTtc }}</td>

                </tr>
{% endfor %}
            </tbody>
        </table>
        <div id="DataTables_Table_0_info" class="dataTables_info">Affichage de {{ (pagination.getCurrentPageNumber -1)*pagination.getItemNumberPerPage + 1}} à {{ (pagination.getCurrentPageNumber -1)*pagination.getItemNumberPerPage + pagination.getItemNumberPerPage}} de {{ pagination.getTotalItemCount }} Devis</div>
{# display navigation #}
        <div id="DataTables_Table_0_paginate" class="dataTables_paginate paging_full_numbers">
    {{ knp_pagination_render(pagination) }}
            </div>
        </div>
        <script>
                    function selectDevis(el, id) {
                        $('#list_devis tbody tr').removeAttr('bgcolor')
                        el.setAttribute('bgcolor', '#E8EAEB')
                        devis_id = id
                    }

                    function chargerDevis() {
                        if (devis_id != -1) {
                            document.documentElement.className += 'loadstate';
                        }
                        $.ajax({
                            url: '{{path('gds_point_vente_charger_devis')}}',
                            data: 'id=' + devis_id,
                            dataType: 'json',
                            success: function(data) {
                                $('#gds_ventebundle_lignedevistype').html('')
                                $('#cboxClose').click()
                                for (i = 0; i < data.length; i++) {
                                    article = data[i]
                                    addLigne(true)
                                }
                                $("html").removeClass("loadstate");
                            }
                        })
                    }
                    function livrerDevis(id) {
                        lf = remplirlf()
                        $.ajax({
                            url: '{{path('gds_devis_livrer')}}',
                            data: 'id=' + id,
                            success: function(data) {
                                $('#div_liste_devis').html(data)
                            }
                        })
                    }
                    function remplirlf() {
                        var liste_f = new Array()
                        liste_f[0] = $('#filtre_numero').val()
                        liste_f[1] = $('#filtre_raison_social').val()
                        liste_f[2] = date1
                        liste_f[3] = date2
                        liste_f[4] = heure1
                        liste_f[5] = heure2
                        liste_f[6] = $('#filtre_reference').val()
                        liste_f[7] = $('#filtre_designation').val()
                        liste_f[8] = $('#filtre_ttc1').val()
                        liste_f[9] = $('#filtre_ttc2').val()
                        liste_f[10] = $('#filtre_type').val()
                        return liste_f
                    }


             {% if is_granted('ROLE_SUPER_ADMIN') %}
                    function removeDevis(id) {
                        $.msgBox({
                            title: "Suppression Devis",
                            content: "Voulez-vous placer le devis dans la corbeille ?",
                            type: "confirm",
                            buttons: [{value: "OUI"}, {value: "NON"}, {value: "Annuler"}],
                            success: function(result) {
                                if (result == "OUI") {
                                    $.ajax({
                                        url: '{{path('gds_devis_delete')}}',
                                        data: 'id=' + id,
                                        success: function(data) {
                                            $.msgBox({
                                                title: "Devis",
                                                content: "Devis placé dans la corbeille",
                                                type: "info",
                                                buttons: [{value: "OK"}],
                                                success: function(result) {
                                                    $('#filtre_numero').keyup()
                                                }
                                            })
                                        },
                                        error: function(data) {
                                            alert('erreur lors de la supression!')
                                        }
                                    })
                                }
                            }
                        });

                    }
            {% endif %}
            </script>{# empty Twig template #}
